package frontend.container;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class ImagePanel extends JPanel{

	private static final long serialVersionUID = -424091847633806866L;
	private Image img;

	  public ImagePanel(String img) {
		  this(new ImageIcon(ClassLoader.getSystemResource(img)).getImage());
	  }

	  public ImagePanel(Image img) {
	    this.img = img;
	    Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
	    setPreferredSize(size);
	    setMinimumSize(size);
	    setMaximumSize(size);
	    setSize(size);
	    layoutComp();
	  }

	  private void layoutComp() {
		  
	  }
	  protected void paintComponent(Graphics g)
	  {
	    super.paintComponent(g); 
	    if (img != null) {
	      g.drawImage(img, 0,0,this.getWidth(),this.getHeight(),this);
	    }
	  }
}
